package com.example.admin.goodnews.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.example.admin.goodnews.R;
import com.example.admin.goodnews.entity.WeeklySalesDataEntity;

/**
 * 单周票房适配器
 * Created by admin on 2016/10/13.
 */

public class WeeklySalesAdapter extends RecyclerView.Adapter<WeeklySalesAdapter.ViewHolder> {
    private Context context;
    private WeeklySalesDataEntity weeklySalesDataEntity;

    public WeeklySalesAdapter(Context context, WeeklySalesDataEntity weeklySalesDataEntity) {
        this.context = context;
        this.weeklySalesDataEntity = weeklySalesDataEntity;
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.item_weeklysales, null);
        ViewHolder holder = new ViewHolder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        holder.tv_moviename_weeklysales.setText("电影名：" + weeklySalesDataEntity.getShowapi_res_body().getDatalist().get(position).getMovieName());
        holder.tv_avgpeople_weeklysales.setText("场均人次：" + weeklySalesDataEntity.getShowapi_res_body().getDatalist().get(position).getAvgPeople());
        holder.tv_boxoffice_weeklysales.setText("票房总计：" + weeklySalesDataEntity.getShowapi_res_body().getDatalist().get(position).getSumWeekAmount());
        holder.tv_weekamount_weeklysales.setText("单日票房：" + weeklySalesDataEntity.getShowapi_res_body().getDatalist().get(position).getWeekAmount());
    }

    @Override
    public int getItemCount() {
        return weeklySalesDataEntity.getShowapi_res_body().getDatalist().size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder {
        private TextView tv_moviename_weeklysales;// 电影名
        private TextView tv_avgpeople_weeklysales;// 场均人次
        private TextView tv_boxoffice_weeklysales;// 票房总计
        private TextView tv_weekamount_weeklysales;// 单日票房

        public ViewHolder(View itemView) {
            super(itemView);
            tv_moviename_weeklysales = (TextView) itemView.findViewById(R.id.tv_moviename_weeklysales);// 电影名
            tv_avgpeople_weeklysales = (TextView) itemView.findViewById(R.id.tv_avgpeople_weeklysales);// 场均人次
            tv_boxoffice_weeklysales = (TextView) itemView.findViewById(R.id.tv_boxoffice_weeklysales);// 票房总计
            tv_weekamount_weeklysales = (TextView) itemView.findViewById(R.id.tv_weekamount_weeklysales);// 单日票房
        }
    }

}
